import collections
class Solution(object):
    def numberOfBoomerangs(self, points):
        """
        :type points: List[List[int]]
        :rtype: int
        """
        n = len(points)
        total = 0
        for i in range(n):
            d = collections.defaultdict(int)
            for j in range(n):
                d[(points[j][0] - points[i][0]) ** 2 + (points[j][1] - points[i][1]) ** 2] += 1
            for key in d:
                total += d[key] * (d[key] - 1)
        return total



data = Solution()
points = [[0, 0], [1, 0], [2, 0]]
